/**
 * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 *
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 */

package de.hsmannheim.pepa.patientenportal.apanwep.model.impl;

import com.liferay.portal.kernel.bean.AutoEscapeBeanHandler;
import com.liferay.portal.kernel.json.JSON;
import com.liferay.portal.kernel.util.GetterUtil;
import com.liferay.portal.kernel.util.ProxyUtil;
import com.liferay.portal.kernel.util.StringBundler;
import com.liferay.portal.kernel.util.StringPool;
import com.liferay.portal.model.CacheModel;
import com.liferay.portal.model.impl.BaseModelImpl;
import com.liferay.portal.service.ServiceContext;

import com.liferay.portlet.expando.model.ExpandoBridge;
import com.liferay.portlet.expando.util.ExpandoBridgeFactoryUtil;

import de.hsmannheim.pepa.patientenportal.apanwep.model.participants;
import de.hsmannheim.pepa.patientenportal.apanwep.model.participantsModel;
import de.hsmannheim.pepa.patientenportal.apanwep.model.participantsSoap;

import java.io.Serializable;

import java.sql.Types;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * The base model implementation for the participants service. Represents a row in the &quot;participants&quot; database table, with each column mapped to a property of this class.
 *
 * <p>
 * This implementation and its corresponding interface {@link de.hsmannheim.pepa.patientenportal.apanwep.model.participantsModel} exist only as a container for the default property accessors generated by ServiceBuilder. Helper methods and all application logic should be put in {@link participantsImpl}.
 * </p>
 *
 * @author Cedric Nana
 * @see participantsImpl
 * @see de.hsmannheim.pepa.patientenportal.apanwep.model.participants
 * @see de.hsmannheim.pepa.patientenportal.apanwep.model.participantsModel
 * @generated
 */
@JSON(strict = true)
public class participantsModelImpl extends BaseModelImpl<participants>
	implements participantsModel {
	/*
	 * NOTE FOR DEVELOPERS:
	 *
	 * Never modify or reference this class directly. All methods that expect a participants model instance should use the {@link de.hsmannheim.pepa.patientenportal.apanwep.model.participants} interface instead.
	 */
	public static final String TABLE_NAME = "participants";
	public static final Object[][] TABLE_COLUMNS = {
			{ "ID", Types.BIGINT },
			{ "Userid", Types.VARCHAR },
			{ "Username", Types.VARCHAR }
		};
	public static final String TABLE_SQL_CREATE = "create table participants (ID LONG not null primary key,Userid VARCHAR(75) null,Username VARCHAR(75) null)";
	public static final String TABLE_SQL_DROP = "drop table participants";
	public static final String ORDER_BY_JPQL = " ORDER BY participants.ID ASC";
	public static final String ORDER_BY_SQL = " ORDER BY participants.ID ASC";
	public static final String DATA_SOURCE = "myDataSource";
	public static final String SESSION_FACTORY = "mySessionFactory";
	public static final String TX_MANAGER = "myTransactionManager";
	public static final boolean ENTITY_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.entity.cache.enabled.de.hsmannheim.pepa.patientenportal.apanwep.model.participants"),
			false);
	public static final boolean FINDER_CACHE_ENABLED = GetterUtil.getBoolean(com.liferay.util.service.ServiceProps.get(
				"value.object.finder.cache.enabled.de.hsmannheim.pepa.patientenportal.apanwep.model.participants"),
			false);
	public static final boolean COLUMN_BITMASK_ENABLED = false;

	/**
	 * Converts the soap model instance into a normal model instance.
	 *
	 * @param soapModel the soap model instance to convert
	 * @return the normal model instance
	 */
	public static participants toModel(participantsSoap soapModel) {
		if (soapModel == null) {
			return null;
		}

		participants model = new participantsImpl();

		model.setID(soapModel.getID());
		model.setUserid(soapModel.getUserid());
		model.setUsername(soapModel.getUsername());

		return model;
	}

	/**
	 * Converts the soap model instances into normal model instances.
	 *
	 * @param soapModels the soap model instances to convert
	 * @return the normal model instances
	 */
	public static List<participants> toModels(participantsSoap[] soapModels) {
		if (soapModels == null) {
			return null;
		}

		List<participants> models = new ArrayList<participants>(soapModels.length);

		for (participantsSoap soapModel : soapModels) {
			models.add(toModel(soapModel));
		}

		return models;
	}

	public static final long LOCK_EXPIRATION_TIME = GetterUtil.getLong(com.liferay.util.service.ServiceProps.get(
				"lock.expiration.time.de.hsmannheim.pepa.patientenportal.apanwep.model.participants"));

	public participantsModelImpl() {
	}

	@Override
	public long getPrimaryKey() {
		return _ID;
	}

	@Override
	public void setPrimaryKey(long primaryKey) {
		setID(primaryKey);
	}

	@Override
	public Serializable getPrimaryKeyObj() {
		return _ID;
	}

	@Override
	public void setPrimaryKeyObj(Serializable primaryKeyObj) {
		setPrimaryKey(((Long)primaryKeyObj).longValue());
	}

	@Override
	public Class<?> getModelClass() {
		return participants.class;
	}

	@Override
	public String getModelClassName() {
		return participants.class.getName();
	}

	@Override
	public Map<String, Object> getModelAttributes() {
		Map<String, Object> attributes = new HashMap<String, Object>();

		attributes.put("ID", getID());
		attributes.put("Userid", getUserid());
		attributes.put("Username", getUsername());

		return attributes;
	}

	@Override
	public void setModelAttributes(Map<String, Object> attributes) {
		Long ID = (Long)attributes.get("ID");

		if (ID != null) {
			setID(ID);
		}

		String Userid = (String)attributes.get("Userid");

		if (Userid != null) {
			setUserid(Userid);
		}

		String Username = (String)attributes.get("Username");

		if (Username != null) {
			setUsername(Username);
		}
	}

	@JSON
	@Override
	public long getID() {
		return _ID;
	}

	@Override
	public void setID(long ID) {
		_ID = ID;
	}

	@JSON
	@Override
	public String getUserid() {
		if (_Userid == null) {
			return StringPool.BLANK;
		}
		else {
			return _Userid;
		}
	}

	@Override
	public void setUserid(String Userid) {
		_Userid = Userid;
	}

	@JSON
	@Override
	public String getUsername() {
		if (_Username == null) {
			return StringPool.BLANK;
		}
		else {
			return _Username;
		}
	}

	@Override
	public void setUsername(String Username) {
		_Username = Username;
	}

	@Override
	public ExpandoBridge getExpandoBridge() {
		return ExpandoBridgeFactoryUtil.getExpandoBridge(0,
			participants.class.getName(), getPrimaryKey());
	}

	@Override
	public void setExpandoBridgeAttributes(ServiceContext serviceContext) {
		ExpandoBridge expandoBridge = getExpandoBridge();

		expandoBridge.setAttributes(serviceContext);
	}

	@Override
	public participants toEscapedModel() {
		if (_escapedModel == null) {
			_escapedModel = (participants)ProxyUtil.newProxyInstance(_classLoader,
					_escapedModelInterfaces, new AutoEscapeBeanHandler(this));
		}

		return _escapedModel;
	}

	@Override
	public Object clone() {
		participantsImpl participantsImpl = new participantsImpl();

		participantsImpl.setID(getID());
		participantsImpl.setUserid(getUserid());
		participantsImpl.setUsername(getUsername());

		participantsImpl.resetOriginalValues();

		return participantsImpl;
	}

	@Override
	public int compareTo(participants participants) {
		long primaryKey = participants.getPrimaryKey();

		if (getPrimaryKey() < primaryKey) {
			return -1;
		}
		else if (getPrimaryKey() > primaryKey) {
			return 1;
		}
		else {
			return 0;
		}
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj) {
			return true;
		}

		if (!(obj instanceof participants)) {
			return false;
		}

		participants participants = (participants)obj;

		long primaryKey = participants.getPrimaryKey();

		if (getPrimaryKey() == primaryKey) {
			return true;
		}
		else {
			return false;
		}
	}

	@Override
	public int hashCode() {
		return (int)getPrimaryKey();
	}

	@Override
	public void resetOriginalValues() {
	}

	@Override
	public CacheModel<participants> toCacheModel() {
		participantsCacheModel participantsCacheModel = new participantsCacheModel();

		participantsCacheModel.ID = getID();

		participantsCacheModel.Userid = getUserid();

		String Userid = participantsCacheModel.Userid;

		if ((Userid != null) && (Userid.length() == 0)) {
			participantsCacheModel.Userid = null;
		}

		participantsCacheModel.Username = getUsername();

		String Username = participantsCacheModel.Username;

		if ((Username != null) && (Username.length() == 0)) {
			participantsCacheModel.Username = null;
		}

		return participantsCacheModel;
	}

	@Override
	public String toString() {
		StringBundler sb = new StringBundler(7);

		sb.append("{ID=");
		sb.append(getID());
		sb.append(", Userid=");
		sb.append(getUserid());
		sb.append(", Username=");
		sb.append(getUsername());
		sb.append("}");

		return sb.toString();
	}

	@Override
	public String toXmlString() {
		StringBundler sb = new StringBundler(13);

		sb.append("<model><model-name>");
		sb.append(
			"de.hsmannheim.pepa.patientenportal.apanwep.model.participants");
		sb.append("</model-name>");

		sb.append(
			"<column><column-name>ID</column-name><column-value><![CDATA[");
		sb.append(getID());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>Userid</column-name><column-value><![CDATA[");
		sb.append(getUserid());
		sb.append("]]></column-value></column>");
		sb.append(
			"<column><column-name>Username</column-name><column-value><![CDATA[");
		sb.append(getUsername());
		sb.append("]]></column-value></column>");

		sb.append("</model>");

		return sb.toString();
	}

	private static ClassLoader _classLoader = participants.class.getClassLoader();
	private static Class<?>[] _escapedModelInterfaces = new Class[] {
			participants.class
		};
	private long _ID;
	private String _Userid;
	private String _Username;
	private participants _escapedModel;
}